<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: pl125 <xskjs888@163.com>
// +----------------------------------------------------------------------

namespace api\admin\model;

use api\common\model\CommonModel;

class FeedbackRecordModel extends CommonModel
{

    /**
     * [addFeedBackRecord description]
     * @param string $value [description]
     */
    public function addFeedBackRecord($data)
    {

        //满意度反馈
        if (!empty($data['satisfaction'])) {
            $insetData = [
                't_id' => $data['t_id'],
                'tag_id' => 0,
                'satisfaction' => $data['satisfaction'],
                'create_time'=>time()
            ];

            $result = $this->insert($insetData);
        }

        
        //反馈投诉
        if (!empty($data['tags'])) {

            foreach ($data['tags'] as $key => $value)
            {
                $insetData = [
                    't_id' => $data['t_id'],
                    'tag_id' => $value,
                    'satisfaction' => 0,
                    'create_time'=>time()
                ];
                $result = $this->insert($insetData);
            }

        }

        return empty($result) ? 0 : 1;
    }

}
